package com.cj.http;

import com.cj.Mapper.CoinTransfer;
import com.cj.models.ResultModel;
import com.cj.services.CoinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserCoinForPost {

    @Autowired
    CoinService coinService;

    @PostMapping(path = "/transfer")
    public ResultModel transfer(@RequestBody CoinTransfer coinTransfer) throws Exception {
       if(coinService.transfer(coinTransfer.getFrom(),
               coinTransfer.getTo(),
               coinTransfer.getCoin()
               )){
           return new ResultModel("success",null);
       }
       return new ResultModel("error","转账失败");

    }
}
